<?php
/**
 * CreateTime: 2023/6/8 11:38
 */

namespace App\Models\SMS;

use App\Consts\TableConsts\TableConsts;
use App\Models\BaseModelV2;

class SMSLogModel extends BaseModelV2
{
    protected $table = TableConsts::SMS_LOG;

    protected $primaryKey = 'sms_log_id';

    protected $fillable = [
        'sms_log_id',
        'phone',
        'sms_info',
        'law_case_id',
        'temp_sms_id',
        'created_time',
    ];

    public function getLawCaseCount($lawCaseId){
        return $this->where('law_case_id',$lawCaseId)->count();
    }

    public function getLawCaseList($lawCaseId){
        return $this->select(['phone','created_time','sms_info','temp_sms_id'])->where('law_case_id',$lawCaseId)->get();
    }

    public function getLastCreatedTimeByLawCaseId($lawCaseId){
        return $this->select(['created_time'])->where('law_case_id',$lawCaseId)->orderBy('sms_log_id','DESC')->first();
    }
}